package com.ruoyi.system.service.impl;

import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.JiajiaMallOrder;
import com.ruoyi.system.domain.JiajiaPointsFlow;
import com.ruoyi.system.mapper.JiajiaPointsFlowMapper;
import com.ruoyi.system.service.IJiajiaPointsFlowService;
import com.ruoyi.system.utils.TokenUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * 项目积分流水Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-03-10
 */
@Service
public class JiajiaPointsFlowServiceImpl implements IJiajiaPointsFlowService 
{
    @Autowired
    private JiajiaPointsFlowMapper jiajiaPointsFlowMapper;

    /**
     * 查询项目积分流水
     * 
     * @param id 项目积分流水主键
     * @return 项目积分流水
     */
    @Override
    public JiajiaPointsFlow selectJiajiaPointsFlowById(Long id)
    {
        return jiajiaPointsFlowMapper.selectJiajiaPointsFlowById(id);
    }

    @Override
    public BigDecimal selectAvailablePoints() {
        return jiajiaPointsFlowMapper.selectAvailablePoints(TokenUtil.getUid());
    }

    @Override
    public BigDecimal selectUsedPoints() {
        return jiajiaPointsFlowMapper.selectUsedPoints(TokenUtil.getUid());
    }

    @Override
    public BigDecimal selectTotalPoints() {
        return jiajiaPointsFlowMapper.selectTotalPoints(TokenUtil.getUid());
    }

    /**
     * 查询项目积分流水列表
     * 
     * @param jiajiaPointsFlow 项目积分流水
     * @return 项目积分流水
     */
    @Override
    public List<JiajiaPointsFlow> selectJiajiaPointsFlowList(JiajiaPointsFlow jiajiaPointsFlow)
    {
        return jiajiaPointsFlowMapper.selectJiajiaPointsFlowList(jiajiaPointsFlow);
    }

    /**
     * 新增项目积分流水
     * 
     * @param jiajiaPointsFlow 项目积分流水
     * @return 结果
     */
    @Override
    public int insertJiajiaPointsFlow(JiajiaPointsFlow jiajiaPointsFlow)
    {
        jiajiaPointsFlow.setCreateTime(DateUtils.getNowDate());
        return jiajiaPointsFlowMapper.insertJiajiaPointsFlow(jiajiaPointsFlow);
    }

    /**
     * 修改项目积分流水
     * 
     * @param jiajiaPointsFlow 项目积分流水
     * @return 结果
     */
    @Override
    public int updateJiajiaPointsFlow(JiajiaPointsFlow jiajiaPointsFlow)
    {
        jiajiaPointsFlow.setUpdateTime(DateUtils.getNowDate());
        return jiajiaPointsFlowMapper.updateJiajiaPointsFlow(jiajiaPointsFlow);
    }

    /**
     * 批量删除项目积分流水
     * 
     * @param ids 需要删除的项目积分流水主键
     * @return 结果
     */
    @Override
    public int deleteJiajiaPointsFlowByIds(String ids)
    {
        return jiajiaPointsFlowMapper.deleteJiajiaPointsFlowByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除项目积分流水信息
     * 
     * @param id 项目积分流水主键
     * @return 结果
     */
    @Override
    public int deleteJiajiaPointsFlowById(Long id)
    {
        return jiajiaPointsFlowMapper.deleteJiajiaPointsFlowById(id);
    }


}
